package com.compass.doctor.ui.prescription

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.compass.doctor.base.BaseVBActivity
import com.compass.doctor.databinding.ActivityPrescriptionTypeBinding
import com.compass.framework.constant.CHAT_INFO
import com.compass.framework.constant.KEY_DISEASE_CONTENT
import com.compass.framework.constant.KEY_PATIENT_ID
import com.compass.framework.constant.REFRESH_MESSAGE
import com.compass.framework.ext.onClick
import com.compass.framework.model.Diagnosis
import com.compass.framework.utils.LiveDataBus
import com.netease.yunxin.kit.corekit.im.model.UserInfo

/**
 * Description：
 * Date:2024/10/19 11:09
 */
class PrescriptionTypeActivity : BaseVBActivity<ActivityPrescriptionTypeBinding>() {

    companion object {
        fun start(context: Context, userInfo: UserInfo, patientId: String, presentDiseaseContent:String?) {
            val intent = Intent(context, PrescriptionTypeActivity::class.java)
            intent.putExtra(CHAT_INFO, userInfo)
            intent.putExtra(KEY_PATIENT_ID, patientId)
            intent.putExtra(KEY_DISEASE_CONTENT, presentDiseaseContent)
            context.startActivity(intent)
        }
    }
    private var presentDiseaseContent:String?=null
    private lateinit var diagnosis: Diagnosis//接收传递过来的诊断数据
    private lateinit var patientId: String//患者ID
    private lateinit var userInfo: UserInfo//云信信息
    override fun initView(savedInstanceState: Bundle?) {
        patientId = intent.serializable(KEY_PATIENT_ID)!!
        userInfo = intent.serializable(CHAT_INFO)!!
        presentDiseaseContent = intent.getStringExtra(KEY_DISEASE_CONTENT)
    }

    override fun initData() {
        LiveDataBus.get().with(REFRESH_MESSAGE, String::class.java)
            .observe(this) {
                //接收开处方成功
                finish()
            }
    }
    override fun intListener() {
        mBinding.contactLayoutPatent.onClick {
            //快速开药/处方开药
            PrescribeForWesternMedicineActivity.start(
                this,
                userInfo,
                patientId,
                presentDiseaseContent
            )

        }

        mBinding.contactLayoutChinese.onClick {
            ChineseMedicinePrescriptionActivity.start(   this,
                userInfo,
                patientId,
                presentDiseaseContent)
        }

    }

}